﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using Emgu.CV;
using Emgu.Util;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;
using System.Drawing.Imaging;
using System.Xml;

namespace FaceDetection
{
    partial class Form1
    {
        private Capture cap;
        //private HaarCascade haar;
        Image<Gray , byte> gray_frame = null;
        Image<Bgr , Byte> currentFrame;
        Image<Gray , byte> result = null;

        //Classifier
        HaarCascade Face = new HaarCascade(Application.StartupPath + "/Cascades/haarcascade_frontalface_alt2.xml");//haarcascade_frontalface_alt_tree.xml");;

        //For aquiring 1 images in a row
        List<Image<Gray , byte>> resultImages = new List<Image<Gray , byte>>( );
        int num_faces_to_aquire = 5;
        bool RECORD = false;
        ImageCodecInfo Image_Encoder_JPG;

        int cnt = 1;
        EncoderParameter ENC = new EncoderParameter( System.Drawing.Imaging.Encoder.Quality , 100 );
        EncoderParameters ENC_Parameters = new EncoderParameters( 1 );

        List<string> NamestoWrite = new List<string>( );
        List<string> NamesforFile = new List<string>( );
        XmlDocument docu = new XmlDocument( );

        Classifier_Train Eigen_Recog = null;
        MCvFont font = new MCvFont( FONT.CV_FONT_HERSHEY_COMPLEX , 0.5 , 0.5 );

        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;
        //private object nextFrame;
        private PictureBox face_PICBX;
        private Button RegisterUser;
        private PictureBox image_PICBX;
        private Button StartCapture;
        private TextBox NAME_PERSON;
        private Label count_lbl;
        private Button ValidateUser;
        private Label message_bar;
        private Button reset;
        private Button stopCapturing;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.face_PICBX = new System.Windows.Forms.PictureBox( );
            this.RegisterUser = new System.Windows.Forms.Button( );
            this.image_PICBX = new System.Windows.Forms.PictureBox( );
            this.StartCapture = new System.Windows.Forms.Button( );
            this.NAME_PERSON = new System.Windows.Forms.TextBox( );
            this.count_lbl = new System.Windows.Forms.Label( );
            this.ValidateUser = new System.Windows.Forms.Button( );
            this.message_bar = new System.Windows.Forms.Label( );
            this.reset = new System.Windows.Forms.Button( );
            this.stopCapturing = new System.Windows.Forms.Button( );
            ( ( System.ComponentModel.ISupportInitialize )( this.face_PICBX ) ).BeginInit( );
            ( ( System.ComponentModel.ISupportInitialize )( this.image_PICBX ) ).BeginInit( );
            this.SuspendLayout( );
            // 
            // face_PICBX
            // 
            this.face_PICBX.Location = new System.Drawing.Point( 547 , 12 );
            this.face_PICBX.Name = "face_PICBX";
            this.face_PICBX.Size = new System.Drawing.Size( 209 , 196 );
            this.face_PICBX.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.face_PICBX.TabIndex = 5;
            this.face_PICBX.TabStop = false;
            // 
            // RegisterUser
            // 
            this.RegisterUser.Enabled = false;
            this.RegisterUser.Location = new System.Drawing.Point( 693 , 217 );
            this.RegisterUser.Name = "RegisterUser";
            this.RegisterUser.Size = new System.Drawing.Size( 62 , 23 );
            this.RegisterUser.TabIndex = 6;
            this.RegisterUser.Text = "Register";
            this.RegisterUser.UseVisualStyleBackColor = true;
            this.RegisterUser.Click += new System.EventHandler( this.RegisterUser_Click );
            // 
            // image_PICBX
            // 
            this.image_PICBX.Location = new System.Drawing.Point( -1 , 12 );
            this.image_PICBX.Name = "image_PICBX";
            this.image_PICBX.Size = new System.Drawing.Size( 525 , 330 );
            this.image_PICBX.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            this.image_PICBX.TabIndex = 7;
            this.image_PICBX.TabStop = false;
            // 
            // StartCapture
            // 
            this.StartCapture.Location = new System.Drawing.Point( 547 , 249 );
            this.StartCapture.Name = "StartCapture";
            this.StartCapture.Size = new System.Drawing.Size( 104 , 36 );
            this.StartCapture.TabIndex = 8;
            this.StartCapture.Text = "Start Capturing";
            this.StartCapture.UseVisualStyleBackColor = true;
            this.StartCapture.Click += new System.EventHandler( this.StartCapture_Click );
            // 
            // NAME_PERSON
            // 
            this.NAME_PERSON.Location = new System.Drawing.Point( 547 , 217 );
            this.NAME_PERSON.Name = "NAME_PERSON";
            this.NAME_PERSON.Size = new System.Drawing.Size( 140 , 20 );
            this.NAME_PERSON.TabIndex = 9;
            // 
            // count_lbl
            // 
            this.count_lbl.AutoSize = true;
            this.count_lbl.Location = new System.Drawing.Point( 530 , 345 );
            this.count_lbl.Name = "count_lbl";
            this.count_lbl.Size = new System.Drawing.Size( 0 , 13 );
            this.count_lbl.TabIndex = 11;
            // 
            // ValidateUser
            // 
            this.ValidateUser.Location = new System.Drawing.Point( 547 , 308 );
            this.ValidateUser.Name = "ValidateUser";
            this.ValidateUser.Size = new System.Drawing.Size( 227 , 31 );
            this.ValidateUser.TabIndex = 12;
            this.ValidateUser.Text = "Validate User";
            this.ValidateUser.UseVisualStyleBackColor = true;
            this.ValidateUser.Click += new System.EventHandler( this.ValidateUser_Click );
            // 
            // message_bar
            // 
            this.message_bar.AutoSize = true;
            this.message_bar.Location = new System.Drawing.Point( 12 , 345 );
            this.message_bar.Name = "message_bar";
            this.message_bar.Size = new System.Drawing.Size( 13 , 13 );
            this.message_bar.TabIndex = 13;
            this.message_bar.Text = "..";
            // 
            // reset
            // 
            this.reset.Location = new System.Drawing.Point( 662 , 345 );
            this.reset.Name = "reset";
            this.reset.Size = new System.Drawing.Size( 112 , 23 );
            this.reset.TabIndex = 14;
            this.reset.Text = "Reset";
            this.reset.UseVisualStyleBackColor = true;
            this.reset.Click += new System.EventHandler( this.reset_Click );
            // 
            // stopCapturing
            // 
            this.stopCapturing.Location = new System.Drawing.Point( 662 , 249 );
            this.stopCapturing.Name = "stopCapturing";
            this.stopCapturing.Size = new System.Drawing.Size( 103 , 36 );
            this.stopCapturing.TabIndex = 15;
            this.stopCapturing.Text = "Stop Capturing";
            this.stopCapturing.UseVisualStyleBackColor = true;
            this.stopCapturing.Click += new System.EventHandler( this.stopCapturing_Click );
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF( 6F , 13F );
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size( 777 , 375 );
            this.Controls.Add( this.stopCapturing );
            this.Controls.Add( this.reset );
            this.Controls.Add( this.message_bar );
            this.Controls.Add( this.ValidateUser );
            this.Controls.Add( this.count_lbl );
            this.Controls.Add( this.NAME_PERSON );
            this.Controls.Add( this.StartCapture );
            this.Controls.Add( this.image_PICBX );
            this.Controls.Add( this.RegisterUser );
            this.Controls.Add( this.face_PICBX );
            this.MaximizeBox = false;
            this.Name = "Form1";
            this.Text = "Face Detection & Reognition";
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler( this.Form1_FormClosing );
            ( ( System.ComponentModel.ISupportInitialize )( this.face_PICBX ) ).EndInit( );
            ( ( System.ComponentModel.ISupportInitialize )( this.image_PICBX ) ).EndInit( );
            this.ResumeLayout( false );
            this.PerformLayout( );

        }

        #endregion

        
    }
}